<template>
  <div class="app_container">
    <flex-container size="10px" style="background-color: white" class="p-15">
      <div slot="header">
        <el-form :inline="true" :model="formInline">
          <el-form-item label="账号/工厂名称">
            <el-input
              v-model="queryParams.name"
              placeholder="审批人"
            ></el-input>
          </el-form-item>
          <el-form-item label="是否认证">
            <el-select
              v-model="queryParams.isCertify"
              placeholder="活动区域"
              @change="GetListPage"
            >
              <el-option :label="'全部认证状态'" :value="-1" />
              <el-option
                v-for="item in authentication"
                :key="item.optionId + '_authentication'"
                :label="item.label"
                :value="item.value"
              />
            </el-select>
          </el-form-item>
          <el-form-item label="账号状态">
            <el-select
              v-model="queryParams.enable"
              placeholder="活动区域"
              @change="GetListPage"
            >
              <el-option :label="'全部账号状态'" :value="-1" />
              <el-option
                v-for="item in isTrueList"
                :key="item.optionId + '_isTrue'"
                :label="item.label"
                :value="item.value"
              />
            </el-select>
          </el-form-item>
          <el-form-item>
            <el-button type="primary" @click="GetList">查询</el-button>
            <el-button type="" @click="ResetForm">重置</el-button>
          </el-form-item>
        </el-form>
        <el-button type="primary" @click="OpenAdd">新增工厂</el-button>
      </div>
      <div>
        <el-table :data="factoryTable.dataSource" border style="width: 100%">
          <el-table-column prop="principalTel" label="登录账号" width="">
          </el-table-column>
          <el-table-column prop="name" label="工厂名称" width="">
          </el-table-column>
          <el-table-column prop="principal" label="负责人" width="">
          </el-table-column>
          <el-table-column prop="principalTel" label="负责人电话" width="">
          </el-table-column>
          <el-table-column prop="amount" label="可用余额" width="">
            <template #default="{ row }">
              {{ row.amount.toFixed(2) }}
            </template>
          </el-table-column>
          <el-table-column prop="frozenAmount" label="暂冻结" width="">
            <template #default="{ row }">
              {{ row.frozenAmount.toFixed(2) }}
            </template>
          </el-table-column>
          <el-table-column prop="settleAmount" label="已结算" width="">
            <template #default="{ row }">
              {{ row.settleAmount.toFixed(2) }}
            </template>
          </el-table-column>
          <el-table-column prop="chargeAmount" label="总充值" width="">
            <template #default="{ row }">
              {{ row.chargeAmount.toFixed(2) }}
            </template>
          </el-table-column>
          <el-table-column prop="name" label="诚意金" width="">
          </el-table-column>
          <el-table-column prop="withdrawAmount" label="总提现" width="">
            <template #default="{ row }">
              {{ row.withdrawAmount.toFixed(2) }}
            </template>
          </el-table-column>
          <el-table-column prop="isCertify" label="是否认证" width="">
            <template #default="{ row }">
              <span
                :class="
                  row.isCertify == 1
                    ? 'text-success'
                    : row.isCertify == 0
                    ? 'text-danger'
                    : ''
                "
                >{{
                  row.isCertify == 1
                    ? "已认证"
                    : row.isCertify == 0
                    ? "未认证"
                    : ""
                }}</span
              >
            </template>
          </el-table-column>
          <el-table-column prop="enable" label="账号状态" width="">
            <template #default="{ row }">
              <span
                :class="
                  row.enable == 1
                    ? 'text-success'
                    : row.enable == 0
                    ? 'text-danger'
                    : ''
                "
                >{{
                  row.enable == 1 ? "启用" : row.enable == 0 ? "禁用" : ""
                }}</span
              >
            </template>
          </el-table-column>
          <el-table-column prop="createTime" label="入驻时间" width="140">
            <template #default="{ row }">
              <!--字符串中T删掉 -->
              {{ row.createTime.replace("T", " ") }}
            </template>
          </el-table-column>
          <el-table-column prop="" label="操作">
            <template #default="{ row }">
              <el-button size="small" type="info" @click="OpenEdit(row)"
                >编辑</el-button
              >
            </template>
          </el-table-column>
        </el-table>
      </div>
      <div>
        <pagination
          v-show="total > 0"
          :total="total"
          :page.sync="queryParams.pageIndex"
          :limit.sync="queryParams.pageSize"
          @pagination="GetList"
        />
      </div>
    </flex-container>
    <vxe-modal
      v-model="addOpen"
      width="900"
      :mask="false"
      :lockView="false"
      class="employees_box"
    >
      <template #title>
        <span>新增工厂账号</span>
      </template>
      <template #default>
        <el-form
          ref="addDataForm"
          :model="addData"
          :rules="addDataRules"
          label-width="120px"
        >
          <el-row class="add_user_box">
            <el-col :span="12">
              <el-form-item label="工厂名称" prop="factoryName">
                <el-input
                  v-model="addData.factoryName"
                  ref="factoryNameInput"
                  @keyup.enter.native="ChangeInput('principalInput')"
                  maxlength="50"
                  placeholder="请输入用户昵称"
                />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="负责人姓名" prop="principal">
                <el-input
                  v-model="addData.principal"
                  @keyup.enter.native="ChangeInput('principalTelInput')"
                  ref="principalInput"
                  maxlength="50"
                  placeholder="请输入真实姓名"
                />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="负责人电话" prop="principalTel">
                <el-input
                  v-model="addData.principalTel"
                  @keyup.enter.native="ChangeInput('addSubmit')"
                  ref="principalTelInput"
                  maxlength="50"
                  placeholder="请输入手机号"
                />
              </el-form-item>
            </el-col>
            <el-col :span="24" class="flex-box l-c-c">
              <el-button type="primary" @click="SubmitFormEdit"
                >确 定</el-button
              >
              <el-button @click="addOpen = false">取 消</el-button>
            </el-col>
          </el-row>
        </el-form>
      </template>
    </vxe-modal>
    <vxe-modal
      v-model="editOpen"
      width="900"
      :mask="false"
      :lockView="false"
      class="employees_box"
    >
      <template #title>
        <span>编辑工厂账号</span>
      </template>
      <template #default>
        <el-tabs type="border-card" v-model="editTab" @tab-click="GetEditTab">
          <el-tab-pane label="工厂信息" name="userInfo">
            <el-form
              ref="editDataForm"
              :model="editData"
              :rules="editDataRules"
              label-width="120px"
            >
              <el-row class="edit_user_box">
                <el-col :span="12">
                  <el-form-item label="工厂名称" prop="factoryName">
                    <el-input
                      v-model="editData.name"
                      ref="factoryNameInput"
                      @keyup.enter.native="ChangeInput('principalInput')"
                      maxlength="50"
                      placeholder="请输入用户昵称"
                    />
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item label="账号状态">
                    <el-radio-group v-model="editData.enable">
                      <el-radio
                        :label="item.value"
                        v-for="item in isTrueList"
                        :key="item.value + '_enabled'"
                      >
                        {{ item.label }}</el-radio
                      >
                    </el-radio-group>
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item label="负责人姓名" prop="principal">
                    <el-input
                      v-model="editData.principal"
                      @keyup.enter.native="ChangeInput('principalTelInput')"
                      ref="principalInput"
                      maxlength="50"
                      placeholder="请输入真实姓名"
                    />
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item label="负责人电话" prop="principalTel">
                    <el-input
                      v-model="editData.principalTel"
                      @keyup.enter.native="ChangeInput('addSubmit')"
                      ref="principalTelInput"
                      maxlength="50"
                      placeholder="请输入手机号"
                    />
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item label="技术姓名">
                    <el-input
                      v-model="editData.techie"
                      @keyup.enter.native="ChangeInput('principalTelInput')"
                      ref="principalInput"
                      maxlength="50"
                      placeholder="请输入真实姓名"
                    />
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item label="技术电话">
                    <el-input
                      v-model="editData.techieTel"
                      @keyup.enter.native="ChangeInput('addSubmit')"
                      ref="principalTelInput"
                      maxlength="50"
                      placeholder="请输入手机号"
                    />
                  </el-form-item>
                </el-col>
                <el-col :span="24">
                  <el-form-item label="地址信息">
                    <el-input
                      clearable
                      v-model="editData.address"
                      ref="addressInput"
                      @focus="OpenAddress()"
                      placeholder="请输入地址"
                    />
                  </el-form-item>
                </el-col>

                <el-col :span="12">
                  <el-form-item label="隐藏师傅名字">
                    <el-radio-group v-model="editData.showMasterName">
                      <el-radio :label="0"> 隐藏</el-radio>
                      <el-radio :label="1"> 显示</el-radio>
                    </el-radio-group>
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item label="隐藏师傅电话">
                    <el-radio-group v-model="editData.showMasterPhone">
                      <el-radio :label="0"> 隐藏</el-radio>
                      <el-radio :label="1"> 显示</el-radio>
                    </el-radio-group>
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item label="自动完结天数">
                    <!-- <el-input-number
                  v-model="editData.autoEndDay"
                  :min="-1"
                  :max="14"
                /> -->
                    <el-input-number
                      v-model="editData.autoEndDay"
                      :min="-1"
                      :max="10"
                      label="描述文字"
                      size="small"
                    ></el-input-number>
                  </el-form-item>
                </el-col>
                <el-col :span="24">
                  <el-form-item label="备注 ">
                    <el-input
                      v-model="editData.remark"
                      ref="remarkInput"
                      type="textarea"
                      :rows="4"
                      placeholder="请输入备注 "
                    />
                  </el-form-item>
                </el-col>
                <el-col :span="24" class="flex-box l-c-c">
                  <el-button type="primary" @click="SubmitFormEdit"
                    >确 定</el-button
                  >
                  <el-button @click="editOpen = false">取 消</el-button>
                </el-col>
              </el-row>
            </el-form>
          </el-tab-pane>

          <el-tab-pane label="产品配置" :name="'products'">
            <div>
              <el-button type="primary" @click="OpenAddProduct"
                >新增产品</el-button
              >
            </div>
            <div class="factory_product_list">
              <el-table
                :data="factoryProductList"
                border
                style="width: 100%"
                height="400"
              >
                <el-table-column prop="productName" label="产品名称" width="">
                </el-table-column>
                <el-table-column
                  prop="productTypeName"
                  label="产品规格"
                  width=""
                >
                </el-table-column>
                <!-- <el-table-column prop="principal" label="产品型号" width="">
                </el-table-column> -->
              </el-table>
            </div>
            <pagination
              v-show="factoryProductTotal > 0"
              :total="factoryProductTotal"
              :page.sync="factoryProductParams.pageIndex"
              :limit.sync="factoryProductParams.pageSize"
              @pagination="GetProductList"
            />
            <!-- <el-col :span="24" class="flex-box l-c-c list_power_btn">
              <el-button @click="editOpen = false">取 消</el-button>
            </el-col> -->
          </el-tab-pane>
          <el-tab-pane label="费用模板" :name="'freeTab'">
            <!--  v-loading="loadingPower" -->
            <el-col :span="3">
              <div>模板类型</div>
            </el-col>
            <el-col :span="5" class="flex-box l-c-c list_power_btn">
              <el-select
                v-model="queryFreeData.templateType"
                placeholder="请选择模板类型"
              >
                <el-option label="维修费用模板" value="RepairFeeType">
                </el-option>
                <el-option label="安装费用模板" value="InstallFeeType">
                </el-option>
                <el-option label="拆装费用模板" value="DestuffFeeType">
                </el-option>
                <el-option label="附加费用模板" value="AdditionFeeType">
                </el-option>
              </el-select>
            </el-col>

            <el-col :span="3">
              <div>产品名称</div>
            </el-col>
            <el-col :span="5">
              <el-select
                v-model="queryFreeData.productID"
                placeholder="请选择产品名称"
                @change="ChangeProductNameList"
              >
                <el-option
                  v-for="item in productNameList"
                  :key="item.productID + '_product'"
                  :label="item.productName"
                  :value="item.productID"
                >
                </el-option>
              </el-select>
            </el-col>
            <el-col :span="3">
              <div>产品分类</div>
            </el-col>
            <el-col :span="5">
              <el-select
                v-model="queryFreeData.productTypeID"
                placeholder="请选择产品分类"
              >
                <el-option
                  v-for="item in productTypeList"
                  :key="item.productTypeID + '_productType'"
                  :label="item.productTypeName"
                  :value="item.productTypeID"
                >
                </el-option>
              </el-select>
            </el-col>
             <el-col :span="3">
              <div>产品型号</div>
            </el-col>
            <el-col :span="5">
              <el-select
                v-model="queryFreeData.productSpecID"
                placeholder="请选择产品分类"
              >
                <el-option
                  v-for="item in productSpecList"
                  :key="item.productTypeID + '_productType'"
                  :label="item.productTypeName"
                  :value="item.productTypeID"
                >
                </el-option>
              </el-select>
            </el-col>
            <el-col :span="24" class="flex-box l-c-c list_power_btn">
              <el-button @click="editOpen = false">取 消</el-button>
            </el-col>
          </el-tab-pane>
          <el-tab-pane label="操作日志" :name="'operateRecording'">
            <!--  v-loading="loadingPower" -->

            <el-col :span="24" class="flex-box l-c-c list_power_btn">
              <!-- <el-button type="primary" @click="SubmitPowerEdit"
                  >确 定</el-button
                > -->
              <el-button @click="editOpen = false">取 消</el-button>
            </el-col>
          </el-tab-pane>
        </el-tabs>
      </template>
    </vxe-modal>
    <el-dialog title="新增产品信息" :visible.sync="addProductOpen" width="30%">
      <el-form
        :model="addProductData"
        :rules="addProductDataRules"
        label-width="80px"
        ref="addProductDataForm"
      >
        <el-form-item label="产品名称" prop="productID">
          <el-select
            filterable
            v-model="addProductData.productID"
            @change="GetProductSpecList"
            placeholder="请选择产品"
          >
            <el-option
              v-for="item in productList"
              :key="item.id + '_product'"
              :label="item.name"
              :value="item.id"
            >
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="产品规格" prop="productTypeID">
          <el-select
            filterable
            v-model="addProductData.productTypeID"
            placeholder="请选择产品规格"
          >
            <el-option
              v-for="item in productSpecList"
              :key="item.id + '_specification'"
              :label="item.name"
              :value="item.id"
            >
            </el-option>
          </el-select>
        </el-form-item>
        <!-- <el-form-item label="产品型号" prop="model">
          <el-input
            v-model="addProductData.model"
            type="text"
            placeholder="请输入产品型号"
          />
        </el-form-item> -->
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="addProductOpen = false">取 消</el-button>
        <el-button type="primary" @click="SubmitFormAddProduct"
          >确 定</el-button
        >
      </span>
    </el-dialog>
    <AddressInput ref="addressBox" @GetAddress="GetAddress"></AddressInput>
  </div>
</template>
<script>
import {
  addFactoryData,
  queryFactoryList,
  editFactoryData,
  queryFactoryProductList,
  getProductList,
  getProductSpecList,
  addFactoryProduct,
  getFactoryProductOption,
  getFactoryProductTypeOption,
  getFactoryCostTemplate,
} from "@/api/account/factory";
import {
  getCategoryTree,
  getProductSpec,
  updata,
  query,
} from "@/api/system/feetemplate";
import AddressInput from "@/components/AddressInput/index.vue";
import {
  GetValueList,
  // @ts-ignore
} from "@/api/system/options";
export default {
  components: {
    AddressInput,
  },
  data() {
    return {
      formInline: {
        user: "",
        region: "",
      },
      tableData: [
        {
          date: "2016-05-02",
          name: "王小虎",
          address: "上海市普陀区金沙江路 1518 弄",
        },
        {
          date: "2016-05-04",
          name: "王小虎",
          address: "上海市普陀区金沙江路 1517 弄",
        },
        {
          date: "2016-05-01",
          name: "王小虎",
          address: "上海市普陀区金沙江路 1519 弄",
        },
        {
          date: "2016-05-03",
          name: "王小虎",
          address: "上海市普陀区金沙江路 1516 弄",
        },
      ],
      /**新增窗口的开关 */
      addOpen: false,
      /**新增工厂账号参数 */
      addData: {
        /**工厂名称 */
        factoryName: "",
        /**负责任姓名 */
        principal: "",
        /**负责人电话 */
        principalTel: "",
      },
      // 表单校验
      addDataRules: {
        factoryName: [
          { required: true, message: "请输入工厂名称", trigger: "blur" },
        ],
        principal: [
          { required: true, message: "负责人姓名不能为空", trigger: "blur" },
        ],

        principalTel: [
          { required: true, message: "请输入负责人电话", trigger: "blur" },
        ],
      },
      /**工厂数据 */
      factoryTable: {},
      // 查询参数
      queryParams: {
        name: "",
        pageIndex: 1,
        pageSize: 20,
        orderby: "createTime",
        sort: "descending",
        principal: "",
        techie: "",
        enable: -1,
        isCertify: -1,
      },
      loading: false,
      total: 0,
      /**账号启用枚举 */
      isTrueList: [],
      /**认证枚举 */
      authentication: [],
      /**编辑工厂弹框开关 */
      editOpen: false,
      /**编辑工厂账号信息 */
      editData: {},
      /**编辑工厂账号验证规则 */
      editDataRules: {
        name: [{ required: true, message: "请输入工厂名称", trigger: "blur" }],
        principal: [
          { required: true, message: "负责人姓名不能为空", trigger: "blur" },
        ],
        principalTel: [
          { required: true, message: "请输入负责人电话", trigger: "blur" },
        ],
      },
      /**编辑框标签 */
      editTab: "userInfo",
      /**工厂产品列表 */
      factoryProductList: [],
      /**请求工厂产品参数 */
      factoryProductParams: {
        /**工厂id */
        factoryIDs: [],
        //**产品id */
        productIDs: [],
        /**产品类型id */
        productTypeIDs: [],
        pageIndex: 1,
        pageSize: 20,
        orderby: "",
        sort: "descending",
      },
      /**工厂产品总数 */
      factoryProductTotal: 0,
      /**产品选择列表 */
      productList: [],
      /**搜索产品列表名称参数 */
      productNameSearch: "",
      /**新增产品开关 */
      addProductOpen: false,
      /**新增产品信息参数 */
      addProductData: {
        /**产品id */
        productID: "",
        /**产品规格 */
        productTypeID: "",
      },
      /**新增产品验证规则 */
      addProductDataRules: {
        productID: [
          { required: true, message: "请选择产品名称", trigger: "blur" },
        ],
        productTypeID: [
          { required: true, message: "请选择产品规格", trigger: "blur" },
        ],
      },
      /**规格列表 */
      productSpecList: [],
      /**查询工厂费用参数 */
      queryFreeData: {
        /**工厂编号 */
        factoryID: 0,
        /**模板类型 */
        templateType: "RepairFeeType",
        /**描述 : 产品编号 附加费用为0 */
        productID: "",
        /**描述 : 产品类别编号 附加费用为0 */
        productTypeID: "",
        /**描述 : 产品规格编号 附加费用为0 */
        productSpecID: 0,
      },
      /**工厂费用模板列表 */
      freeList: [],
      /**更新工厂费用参数 */
      updateFreeData: {
        templateType: "",
        factoryID: 0,
        productID: 0,
        productTypeID: 0,
        productSpecID: 0,
        items: [
          {
            id: 0,
            feeTypeID: 0,
            content: "",
            factoryAmount: 0,
            masterAmount: 0,
          },
        ],
      },
      /**根据产品id查询产品类别参数 */
      getProductCategoryData: {
        factoryID: "",
        /**产品id */
        productID: "",
        productTypeName: "",
      },
      /**产品名称列表 */
      productNameList: [],
      /**产品类型列表 */
      productTypeList: [],
      /**产品规格费用列表 */
      productSpecFreeList: [],
      /**产品型号列表 */
      productSpecList: [],
      /**产品型号查寻参数 */
      getProductSpecData: {
        /**产品类别id */
        productTypeID: "",
      },
    };
  },
  methods: {
    onSubmit() {
      console.log("submit!");
    },
    /**打开新增工厂账号弹框 */
    OpenAdd() {
      this.addOpen = true;
    },
    /**切换下一个输入框 */
    ChangeInput(text, name = null) {
      if (text == "addSubmit") {
        this.SubmitFormEdit();
        return;
      }
      if (name != null) {
        this.$refs[name].blur();
      }
      this.$refs[text].focus();
    },
    /**新增工厂账号 */
    SubmitFormEdit() {
      this.$refs.addDataForm.validate(async (valid) => {
        if (valid) {
          let { statusCode } = await addFactoryData(this.addData);
          if (statusCode != 200) return;
          this.$message({
            message: "添加成功",
            type: "success",
          });
          this.addOpen = false;

          this.GetList();
        }
      });
    },
    /**接收地址选择回传的数据 */
    GetAddress(row) {
      this.editData.address = row.spellingText;
      this.editData.provinceID = row.provinceId;
      this.editData.cityID = row.cityId;
      this.editData.countyID = row.districtId;
      this.editData.province = row.province;
      this.editData.city = row.city;
      this.editData.county = row.district;
      this.editData.streetID = row.streetId;
      this.editData.street = row.street;
    },
    /**分页 获取工厂账号信息 */
    async GetList() {
      this.loading = true;
      let { data, statusCode } = await queryFactoryList(this.queryParams);
      if (statusCode != 200) return;
      this.factoryTable = data;
      this.total = this.factoryTable.totalCount;
      this.loading = false;
    },
    /**初始数据函数 */
    async InitialData() {
      /**是否启用 */
      let json = await GetValueList("Enabled");
      if (json.statusCode != 200) return;
      json.data.forEach((item) => {
        if (item.dataType == "int") {
          item.value = parseInt(item.value);
        }
      });
      this.isTrueList = json.data;
      let data = await GetValueList("IsCertify");
      if (data.statusCode != 200) return;
      data.data.forEach((item) => {
        if (item.dataType == "int") {
          item.value = parseInt(item.value);
        }
      });
      this.authentication = data.data;
      this.GetList();
    },
    /**重置第一页 */
    GetListPage() {
      this.queryParams.pageIndex = 1;
      this.GetList();
    },
    /**重置参数 */
    ResetForm() {
      this.queryParams = {
        name: "",
        pageIndex: 1,
        pageSize: 20,
        orderby: "createTime",
        sort: "descending",
        principal: "",
        techie: "",
        enable: -1,
        isCertify: -1,
      };
      this.GetList();
    },
    /**打开编辑工厂弹框 */
    OpenEdit(row) {
      this.editData = row;
      this.editTab = "userInfo";
      this.editOpen = true;
    },
    /**打开地址选择地址 */
    OpenAddress() {
      this.$refs.addressBox.OpenAddress();
    },
    /**提交编辑工厂信息 */
    async SubmitFormEdit() {
      this.$refs.editDataForm.validate(async (valid) => {
        if (valid) {
          let { statusCode } = await editFactoryData(this.editData);
          if (statusCode != 200) return;
          this.$message({
            message: "编辑成功",
            type: "success",
          });
          this.editOpen = false;
          this.GetList();
        }
      });
    },
    /**切换编辑标签获取数据 */
    async GetEditTab() {
      if (this.editTab == "products") {
        await this.GetProductList();
        /**请求产品选择列表数据 */
        let { data: productData, statusCode: productCode } =
          await getProductList(this.productNameSearch);
        if (productCode != 200) return;
        // console.log(productData);
        this.productList = productData;
      } else if (this.editTab == "freeTab") {
        /**请求费用模板 */
        // let { data, statusCode } = await getFactoryCostTemplate(
        //   this.queryFreeData
        // );
        // if (statusCode != 200) return;
        // this.freeList = data;
        this.GetProductNameList();
      } else if (this.editTab == "operateRecording") {
        /**请求操作记录 */
      }
    },

    /**获取产品选项列表 */
    async GetProductNameList() {
      let { data, statusCode } = await getFactoryProductOption({
        factoryID: this.editData.id,
      });
      if (statusCode != 200) return;
      this.productNameList = data;
    },
    /**获取产品列表信息 */
    async GetProductList() {
      this.factoryProductParams.factoryIDs = [this.editData.id];
      /**请求工厂产品 */
      let { data, statusCode } = await queryFactoryProductList(
        this.factoryProductParams
      );
      if (statusCode != 200) return;
      this.factoryProductList = data.dataSource;
      this.factoryProductTotal = data.totalCount;
    },
    /**打开新增产品弹框 */
    OpenAddProduct() {
      this.addProductOpen = true;
    },
    /**根据产品获取规格列表 */
    async GetProductSpecList() {
      let { data, statusCode } = await getProductSpecList(
        this.addProductData.productID
      );
      if (statusCode != 200) return;
      this.productSpecList = data;
      this.addProductData.productTypeID = "";
      // console.log(data);
    },
    /**提交新增产品信息 */
    async SubmitFormAddProduct() {
      this.addProductData.factoryID = this.editData.id;
      this.$refs.addProductDataForm.validate(async (valid) => {
        if (valid) {
          let { statusCode } = await addFactoryProduct(this.addProductData);
          if (statusCode != 200) return;
          this.$message({
            message: "添加成功",
            type: "success",
          });
          this.addProductOpen = false;
          // this.GetList();
          this.GetProductList();
        }
      });
    },

    /**查询产品类别 */
    async GetProductCategory() {
      this.getProductCategoryData.factoryID = this.editData.id;
      this.getProductCategoryData.productID = this.queryFreeData.productID;
      let { data, statusCode } = await getFactoryProductTypeOption(
        this.getProductCategoryData
      );
      if (statusCode != 200) return;
      this.productTypeList = data;
    },
    /*产品名称切换获取产品类别 */
    ChangeProductNameList() {
      this.GetProductCategory();
    },

    /** */
    // ChangeInput(text) {},
  },
  created() {
    this.InitialData();
  },
};
</script>

<style lang="scss" scoped src="./index.scss"></style>